package com.onlineclass.util;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidDataSourceFactory;

public class JDBCUtils {

	static Connection conn;
	static Properties properties;
	static DruidDataSource dataSource;
	
	static {
		properties = new Properties();
		try {
			InputStream is = JDBCUtils.class.getClassLoader().getResourceAsStream("druid.properties");
			properties.load(is);
			//创建数据源
			dataSource = (DruidDataSource) DruidDataSourceFactory.createDataSource(properties);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static DruidDataSource getDataSource() {
		return dataSource;
	}

	public static void setDataSource(DruidDataSource dataSource) {
		JDBCUtils.dataSource = dataSource;
	}

}